using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XLua.LuaDLL;

public class GameStart : MonoBehaviour
{
    public GameMode GameMode;

    private void Start()
    {
        Manager.Event.Subscribe(1, OnLuaInitComplete);

        AppConst.GameMode = this.GameMode;
        DontDestroyOnLoad(this);

        Manager.Resources.ParseVersionFile();

        Manager.Lua.InitLuaScript();
            
    }
    
    private void OnLuaInitComplete(Object args)
    {
        Manager.Lua.ExcuteLua("luatest");


        Manager.Pool.CreatGameObjectPool("UI", 10);
        Manager.Pool.CreatGameObjectPool("Monster", 120);
        Manager.Pool.CreatGameObjectPool("Effect", 120);
        Manager.Pool.CreatAssetBundlePool("AssetBundle", 300);

        //调用lua函数的另一种方法
        XLua.LuaFunction func = Manager.Lua.luaEnv.Global.Get<XLua.LuaFunction>("Test");
        func.Call();
    }

    private void OnApplicationQuit()
    {
        Manager.Event.Unsubscribe(1, OnLuaInitComplete);   
    }
}
